﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using App.Interface;
using Newtonsoft.Json;

namespace App.Realization
{
    public class JiaoZhiGongtmpl : IJiaoZhiGong
    {
        public void AddEmployee(string zh, string xm, string sj, int xb, int ksid, int zwid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/AddJiaoZhiGongInfo?zh=" + zh + "&xm=" + xm + "&sjh=" + sj + "&xb=" + xb + "&ksid=" + ksid + "&zwid=" + zwid);
            //return result;
        }

        public void UpdateEmployee(string userid, string xm, string sj, int xb, int ksid, int zwid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/UpdateJiaoZhiGongInfo?userid=" + userid + "&xm=" + xm + "&sjh=" + sj + "&xb=" + xb + "&ksid=" + ksid + "&zwid=" + zwid);
            //return result;
        }

        public void DelEmployee(string userid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/DelJiaoZhiGongInfo?userid=" + userid);
            //return result;
        }

        public string GetEmployees(string keyword, int ksid, int zwid, int pageIndex, int pageSize)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/GetJiaoZhiGongs?keyword=" + keyword + "&ksid=" + ksid + "&zwid=" + zwid + "&pageIndex=" + pageIndex + "&pageSize=" + pageSize);
            return result;
        }

        public string GetEmployee(string userid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/GetJiaoZhiGongInfo?userid=" + userid);
            return result;
        }

        //public void ChangePassword(string userid, string oldpassword, string newpassword)
        //{
        //    var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/ChangePassword?userid=" + userid + "&oldpassword=" + oldpassword + "&newpassword=" + newpassword);
        //}

        public void UpdatePassword(string username, string oldpassword, string newpassword)
        {
            dynamic obj = new { username = username, oldpassword = oldpassword, newpassword = newpassword };
            string str = JsonConvert.SerializeObject(obj);
            var reslut = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/UpdatePassword", str);
        }

        public void ResetPassword(string username)
        {
            dynamic obj = new { username = username };
            string str = JsonConvert.SerializeObject(obj);
            var reslut = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/ResetPassword", str);
        }

        public string GetEmployeebyusername(string username)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/JiaoZhiGong/GetJiaoZhiGongInfoByUsername?username=" + username);
            return result;
        }
    }
}
